import axios from 'axios'
import { Storage } from '../../storage'

const createWork = (form) => axios.post('/api/work/info', form, {
    headers: {
        "nothing-token": Storage.get("nothing-token")
    }
}).then(res => res.data)

const getWorkInTheCourseId = (courseId) => axios.get(`/api/work/info/course/${courseId}`)
    .then(res => res.data)

const getWorkInfoByID = (workId) => axios.get(`/api/work/info/${workId}`).then(res => res.data)


const updateTheWork = (form) => axios.put('/api/work/info', form).then(res => res.data)

const getWorkRecords = workId => axios.get(`/api/work/record/in/${workId}`).then(res => res.data)

const correctWorkSubmitRecord = (wsId, score) => axios.post(`/api/work-record/correct`, { workSubmitId: wsId, score }).then(res => res.data)

const getWorkPospone = () => axios.get("/api/work-postpone/get/false", {
    headers: {
        "nothing-token": Storage.get("nothing-token")
    }
}).then(res => res.data)

const getWorkCondition = wpId => axios.get(`/api/work-postpone/condition/${wpId}`).then(res => res.data)

const decidePostpone = (wpId, form) => axios.put(`/api/work-postpone/decide/${wpId}`, form).then(res => res.data)

export {
    createWork,
    getWorkInTheCourseId,
    getWorkInfoByID,
    updateTheWork,
    getWorkRecords,
    correctWorkSubmitRecord,
    getWorkPospone,
    getWorkCondition,
    decidePostpone
}